import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;


public class Client {

	private final static int SERVR_PORT = 1235;
	private final static int MY_PORT = 5000;
	private final static String SERVER_IP = "172.23.168.37";
	private DatagramSocket mySocket = null;
	
	public Client() {
		
		try {
			this.mySocket = new DatagramSocket(MY_PORT);
		} catch (SocketException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void send(RtpPacket rtpPacket) {		

		byte[] rtpPacketBytes = rtpPacket.getRtpPacket();		
		DatagramPacket datagramPacket;
		
		try {
			datagramPacket = new DatagramPacket(new byte[1], 1, InetAddress.getByName(SERVER_IP), SERVR_PORT);
			datagramPacket.setData(rtpPacketBytes);
			System.out.println("Size: "+datagramPacket.getData().length);
			
			this.mySocket.send(datagramPacket);
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
	public void recv() {
		
		
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		RtpPacket rtpPacket = new RtpPacket();
		rtpPacket.setV(2);
		rtpPacket.setP(1);
		rtpPacket.setM(1);
		rtpPacket.setSN(1234);
		rtpPacket.setPayload(new byte[512], 512);
		
		Client client = new Client();
		client.send(rtpPacket);
		
		
		
	}

}
